<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:cms="http://thymeleafexamples">
<head th:include="include/head">

</head>
<style>
	.content-wrapper, .main-footer, .main-header{
		margin-left: 0;
	}
</style>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">


	<div class="content-wrapper">
		<!-- Content Header (Page header) -->
		<section class="content-header">
			<div class="container-fluid">
				<div class="row mb-2">
					<div class="col-sm-6">
						<h1>资料库</h1>
					</div>
					<div class="col-sm-6">
						<ol class="breadcrumb float-sm-right">
							<li class="breadcrumb-item"><a href="#">首页</a></li>
							<li class="breadcrumb-item active">资料库</li>
						</ol>
					</div>
				</div>
			</div>
			<!-- /.container-fluid -->
		</section>

		<!-- Main content -->
		<section class="content">
			<div class="container-fluid">
				<div class="row">
					<div class="col-md-12">
						<div class="card">
							<div class="card-header">
								<h3 class="card-title">资料库列表</h3>
								<button type="button" class="btn btn-primary btn-sm" id="add" style="float: right">新增</button>
							</div>
							<div class="card-header">
								<form id="search-form2" class="navbar-form form-inline"  th:action="@{/library/rlist}" method="post">
									<div class="form-group " >
										<label>归属部门:</label>
										<div class="col-sm-2" >
											<!--												0新增；1处理中；2挂起；3已完成-->
											<select  class="form-control"   id="baseId" name="baseId" >
												<option value="">全部</option>
												<option  th:each="model : ${baseList}" th:value="${model.baseId}"
														 th:text="${model.baseName}" th:selected="${model.baseId}==${baseId}" value="0">否</option>
											</select>
										</div>
									</div>
									<div class="form-group " >
										<label>创建者:</label>
										<div class="col-sm-4" >
											<input type="text" name="uname" th:value="${uname}" placeholder="创建者" class="form-control">
										</div>
									</div>
									<div class="form-group " >
										<label>标题:</label>
										<div class="col-sm-4" >
											<input type="text" name="name" th:value="${name}" placeholder="名称" class="form-control">
										</div>
									</div>
									<div class="form-group " >
										<button type="button" id="serch"  style="font-size:0.5rem;" class="btn btn-primary pull-right">查询</button>
									</div>
								</form>

							</div>
							<!-- /.card-header -->
							<div class="card-body">
								<table class="table table-bordered">
									<thead>
									<tr>
										<!-- 												<th style="width: 10px">#</th> -->
										<th>名称</th>
										<th style="width: 200px"> 描述</th>
										<th>创建时间</th>
										<th>创建者</th>
										<th>归属部门</th>
										<th>附件类型</th>
										<th>是否必读</th>
										<th>是否启用</th>
										<th>排序</th>
										<!-- 												<th style="width: 150px;">移动</th> -->
										<th style="width: 250px">操作</th>
									</tr>
									</thead>
									<tbody id="content">
									<tr th:each="bean : ${pageInfo.list}" th:attr="id=tr_+${bean.dataId}">
										<!--												<td th:text="${bean.dataCode}"></td>-->
										<td th:text="${bean.dataName}"></td>
										<td th:text="${bean.dataDesc}"></td>
										<td><cms:time timeInt="${bean.createTime}"></cms:time></td>
										<td th:text="${bean.operName}"></td>
										<td th:text="${bean.baseName}"></td>
										<td th:switch="${bean.fileType}">
											<span th:case="0">无附件</span>
											<span th:case="1">pdf</span>
											<span th:case="2">doc</span>
											<span th:case="3">视频</span>
										</td>
										<td th:text="${bean.isRequired==0?'否':'是'}">
										<td th:text="${bean.dataState==0?'禁用':'启用'}"></td>
										<td th:text="${bean.back3}"></td>
										<!-- 												<td> -->
										<!-- 													<button type="button" class="btn btn-primary btn-sm sortUp" -->
										<!-- 														th:attr="data-id=|${bean.userId}">上移</button> -->
										<!-- 													<button type="button" class="btn btn-info btn-sm sortDown" -->
										<!-- 														th:attr="data-id=|${bean.userId}">下移</button> -->
										<!-- 												</td> -->
										<td>
											<a th:href="'radd?id='+${bean.dataId}" class="btn btn-info btn-sm">
												<i class="fas fa-pencil-alt"></i>编辑
											</a> &nbsp;&nbsp;
											<a href="javascript:;" th:attr="data-id=|${bean.dataId}" class="btn btn-danger btn-sm del">
												<i class="fas fa-trash"></i>删除
											</a>
										</td>
									</tr>
									</tbody>
								</table>
							</div>
							<cms:page></cms:page>
						</div>

					</div>
				</div>
			</div>
		</section>
	</div>
</div>
<!-- ./wrapper -->
<div th:include="include/foot"></div>
<script>
	$("#hospitalId").change(function (){
		let v=$(this).val();
		let t= $(this).find("option:selected").text();
		console.log(v,t)
		if(v>0){
			$("#hospitalName").val(t);
		}
		$.ajax({url:'../doctor/departmentList',data:"hospitalId="+v,success:function (data){
				if(data.res){
					$("#dpId").empty();
					$("#dpId").append("<option value=''>请选择科室</option>");
					for(let i=0;i<data.list.length;i++){
						console.log(data.list[i])
						$("#dpId").append("<option value='"+data.list[i].id+"'>"+data.list[i].departmentName+"</option>");
					}

				}
			}})
	});
	$("#serch").click(function() {
		$("#search-form2").submit();
	});
	$().ready(function() {
		$("#add").click(function() {
			location.href = 'radd';
		});

		$(".del").click(function() {
			if (confirm('确定删除内容吗？')) {
				let id = $(this).data('id');
				$.ajax({
					url : 'del?id=' + id,
					success : function(e) {
						if (e.res) {
							$("#tr_" + id).remove();
							layer.msg('删除成功', {icon: 1})
						}
					},error:function(e){
						layer.msg(e.responseText, {icon: 5});
					}
				});
			}

		});
	});
</script>
</body>
</html>
